package o;

import androidx.annotation.NonNull;

class tq<Z> implements tx<Z> {
    private boolean ʽ;
    private final boolean ˊ;
    private final boolean ˋ;
    private final c ˎ;
    private final sa ˏ;
    private final tx<Z> ॱ;
    private int ॱॱ;

    interface c {
        void ˏ(sa saVar, tq<?> tqVar);
    }

    tq(tx<Z> txVar, boolean z, boolean z2, sa saVar, c cVar) {
        this.ॱ = (tx) aas.ˎ(txVar);
        this.ˋ = z;
        this.ˊ = z2;
        this.ˏ = saVar;
        this.ˎ = (c) aas.ˎ(cVar);
    }

    tx<Z> ˊ() {
        return this.ॱ;
    }

    boolean ˏ() {
        return this.ˋ;
    }

    @NonNull
    public Class<Z> ˎ() {
        return this.ॱ.ˎ();
    }

    @NonNull
    public Z ˋ() {
        return this.ॱ.ˋ();
    }

    public int ॱ() {
        return this.ॱ.ॱ();
    }

    public synchronized void ॱॱ() {
        if (this.ॱॱ > 0) {
            throw new IllegalStateException("Cannot recycle a resource while it is still acquired");
        } else if (this.ʽ) {
            throw new IllegalStateException("Cannot recycle a resource that has already been recycled");
        } else {
            this.ʽ = true;
            if (this.ˊ) {
                this.ॱ.ॱॱ();
            }
        }
    }

    synchronized void ʼ() {
        if (this.ʽ) {
            throw new IllegalStateException("Cannot acquire a recycled resource");
        }
        this.ॱॱ++;
    }

    void ʽ() {
        Object obj = null;
        synchronized (this) {
            if (this.ॱॱ <= 0) {
                throw new IllegalStateException("Cannot release a recycled or not yet acquired resource");
            }
            int i = this.ॱॱ - 1;
            this.ॱॱ = i;
            if (i == 0) {
                obj = 1;
            }
        }
        if (obj != null) {
            this.ˎ.ˏ(this.ˏ, this);
        }
    }

    public synchronized String toString() {
        return "EngineResource{isMemoryCacheable=" + this.ˋ + ", listener=" + this.ˎ + ", key=" + this.ˏ + ", acquired=" + this.ॱॱ + ", isRecycled=" + this.ʽ + ", resource=" + this.ॱ + '}';
    }
}
